/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "sensor_type")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SensorType.findAll", query = "SELECT s FROM SensorType s"),
    @NamedQuery(name = "SensorType.findById", query = "SELECT s FROM SensorType s WHERE s.id = :id"),
    @NamedQuery(name = "SensorType.findByDescription", query = "SELECT s FROM SensorType s WHERE s.description = :description"),
    @NamedQuery(name = "SensorType.findByNagiosTable", query = "SELECT s FROM SensorType s WHERE s.nagiosTable = :nagiosTable"),
    @NamedQuery(name = "SensorType.findByNagiosField", query = "SELECT s FROM SensorType s WHERE s.nagiosField = :nagiosField")})
public class SensorType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private String id;
    @Column(name = "Description")
    private String description;
    @Basic(optional = false)
    @Column(name = "NagiosTable")
    private String nagiosTable;
    @Basic(optional = false)
    @Column(name = "NagiosField")
    private String nagiosField;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "sensorType")
    private Collection<ObservedComponent> observedComponentCollection;
    @OneToMany(mappedBy = "idSensorType")
    private Collection<GpiKpiInstance> gpiKpiInstanceCollection;

    public SensorType() {
    }

    public SensorType(String id) {
        this.id = id;
    }

    public SensorType(String id, String nagiosTable, String nagiosField) {
        this.id = id;
        this.nagiosTable = nagiosTable;
        this.nagiosField = nagiosField;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getNagiosTable() {
        return nagiosTable;
    }

    public void setNagiosTable(String nagiosTable) {
        this.nagiosTable = nagiosTable;
    }

    public String getNagiosField() {
        return nagiosField;
    }

    public void setNagiosField(String nagiosField) {
        this.nagiosField = nagiosField;
    }

    @XmlTransient
    public Collection<ObservedComponent> getObservedComponentCollection() {
        return observedComponentCollection;
    }

    public void setObservedComponentCollection(Collection<ObservedComponent> observedComponentCollection) {
        this.observedComponentCollection = observedComponentCollection;
    }

    @XmlTransient
    public Collection<GpiKpiInstance> getGpiKpiInstanceCollection() {
        return gpiKpiInstanceCollection;
    }

    public void setGpiKpiInstanceCollection(Collection<GpiKpiInstance> gpiKpiInstanceCollection) {
        this.gpiKpiInstanceCollection = gpiKpiInstanceCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SensorType)) {
            return false;
        }
        SensorType other = (SensorType) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.SensorType[ id=" + id + " ]";
    }
    
}
